package com.shanzmoo.db.personnel.entity.dto;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.base.annotation.IntIn;
import com.shanzmoo.db.personnel.entity.RootGroupEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 刷机组保存对象
 *
 * @author: Gzhao 2020/12/15
 */
@Data
@ApiModel("刷机组保存对象")
public class RootGroupSaveDto {

    @IntIn(values = {0, 1, 2}, message = "刷机组类型参数解析异常")
    @ApiModelProperty("类型：0-自营，1-加盟，2-外包")
    private Integer type;

    @NotBlank(message = "组名不允许为空")
    @ApiModelProperty("组名")
    private String name;

    @NotBlank(message = "组长姓名不允许为空")
    @ApiModelProperty("组长姓名")
    private String groupLeader;

    @NotBlank(message = "组长手机号不允许为空")
    @ApiModelProperty("组长手机号")
    private String mobile;

    public static RootGroupEntity convert(RootGroupSaveDto saveDto) {
        return JSON.parseObject(JSON.toJSONString(saveDto), RootGroupEntity.class);
    }
}
